home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
shape.lha
/
shape
/
put_line.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
525b
|
28 lines
include "screen.h"
oid put_line(point a, point b)
put_line(a.x, a.y, b.x, b.y);
oid put_line(int x0, int y0, int x1, int y1)
register dx = 1;
int a = x1 - x0;
if (a < 0) dx = -1, a = -a;
register dy = 1;
int b = y1 - y0;
if (b < 0) dy = -1, b = -b;
int two_a = 2 * a;
int two_b = 2 * b;
int xcrit = -b + two_a;
register eps = 0;
for (;;)
{
put_point(x0, y0);
if (x0 == x1 && y0 == y1) break;
if (eps <= xcrit) x0 += dx, eps += two_b;
if (eps>= a || a <= b) y0 += dy, eps -= two_a;
}